#include <stdio.h>

void max(int * a, int * b)
{
	if (*a < *b)
		*a = *b;
}

int main()
{
	int a = 5, b = 6;

	max(&a, &b);
	printf("a, b max %d\n", a);

	return 0;
}

#if 0

/*
 * intel
 */
0000000000001169 <max>:
    1169:	f3 0f 1e fa          	endbr64 
    116d:	55                   	push   %rbp
    116e:	48 89 e5             	mov    %rsp,%rbp
    1171:	48 89 7d f8          	mov    %rdi,-0x8(%rbp)	// (rbp-0x8)=rdi
    1175:	48 89 75 f0          	mov    %rsi,-0x10(%rbp)	// (rbp-0x10)=rsi
    1179:	48 8b 45 f8          	mov    -0x8(%rbp),%rax	// rax=(rbp-0x8)
    117d:	8b 10                	mov    (%rax),%edx	// edx=(rax)
    117f:	48 8b 45 f0          	mov    -0x10(%rbp),%rax	// rax=(rpb-0x10)
    1183:	8b 00                	mov    (%rax),%eax	// eax=(rax)
    1185:	39 c2                	cmp    %eax,%edx	// edx-eax
    1187:	7d 0c                	jge    1195 <max+0x2c>	// 大于等于(有符号>=)
    1189:	48 8b 45 f0          	mov    -0x10(%rbp),%rax	// rax=(rbp-0x10)
    118d:	8b 10                	mov    (%rax),%edx	// edx=(rax)
    118f:	48 8b 45 f8          	mov    -0x8(%rbp),%rax	// rax=(rbp-0x8)
    1193:	89 10                	mov    %edx,(%rax)	// (rax)=edx
    1195:	90                   	nop
    1196:	5d                   	pop    %rbp
    1197:	c3                   	retq   

0000000000001198 <main>:
    1198:	f3 0f 1e fa          	endbr64 
    119c:	55                   	push   %rbp
    119d:	48 89 e5             	mov    %rsp,%rbp
    11a0:	48 83 ec 10          	sub    $0x10,%rsp
    11a4:	64 48 8b 04 25 28 00 	mov    %fs:0x28,%rax
    11ab:	00 00 
    11ad:	48 89 45 f8          	mov    %rax,-0x8(%rbp)	// (rbp-0x8)=rax
    11b1:	31 c0                	xor    %eax,%eax	// eax=0
    11b3:	c7 45 f0 05 00 00 00 	movl   $0x5,-0x10(%rbp)	// (rbp-0x10)=0x5
    11ba:	c7 45 f4 06 00 00 00 	movl   $0x6,-0xc(%rbp)	// (rbp-0xc)=0c6
    11c1:	48 8d 55 f4          	lea    -0xc(%rbp),%rdx	// rdx=(rbp-0xc)
    11c5:	48 8d 45 f0          	lea    -0x10(%rbp),%rax	// rax=(rbp-0x10)
    11c9:	48 89 d6             	mov    %rdx,%rsi	// rsi=rdx
    11cc:	48 89 c7             	mov    %rax,%rdi	// rdi=rax
    11cf:	e8 95 ff ff ff       	callq  1169 <max>	// max(rdi, rsi)
    11d4:	8b 45 f0             	mov    -0x10(%rbp),%eax	// eax=(rbp-0x10)
    11d7:	89 c6                	mov    %eax,%esi	// esi=eax
    11d9:	48 8d 3d 24 0e 00 00 	lea    0xe24(%rip),%rdi        # 2004 <_IO_stdin_used+0x4>
    11e0:	b8 00 00 00 00       	mov    $0x0,%eax	// eax=0
    11e5:	e8 86 fe ff ff       	callq  1070 <printf@plt>
    11ea:	b8 00 00 00 00       	mov    $0x0,%eax
    11ef:	48 8b 4d f8          	mov    -0x8(%rbp),%rcx
    11f3:	64 48 33 0c 25 28 00 	xor    %fs:0x28,%rcx
    11fa:	00 00 
    11fc:	74 05                	je     1203 <main+0x6b>
    11fe:	e8 5d fe ff ff       	callq  1060 <__stack_chk_fail@plt>
    1203:	c9                   	leaveq 
    1204:	c3                   	retq   
    1205:	66 2e 0f 1f 84 00 00 	nopw   %cs:0x0(%rax,%rax,1)
    120c:	00 00 00 
    120f:	90                   	nop


/*
 * arm
 */
000000000040055c <max>:
  40055c:	d10043ff 	sub	sp, sp, #0x10
  400560:	f90007e0 	str	x0, [sp, #8]	// [sp+8]=x0
  400564:	f90003e1 	str	x1, [sp]	// [sp]=x1
  400568:	f94007e0 	ldr	x0, [sp, #8]	// x0=[sp+8]
  40056c:	b9400001 	ldr	w1, [x0]	// w1=[x0]
  400570:	f94003e0 	ldr	x0, [sp]	// x0=[sp]
  400574:	b9400000 	ldr	w0, [x0]	// w0=[x0]
  400578:	6b00003f 	cmp	w1, w0		// w1-w0
  40057c:	540000aa 	b.ge	400590 <max+0x34>  // b.tcont
  400580:	f94003e0 	ldr	x0, [sp]	// x0=[sp]
  400584:	b9400001 	ldr	w1, [x0]	// w1=[x0]
  400588:	f94007e0 	ldr	x0, [sp, #8]	// x0=[sp+8]
  40058c:	b9000001 	str	w1, [x0]	// [x0]=w1
  400590:	d503201f 	nop
  400594:	910043ff 	add	sp, sp, #0x10
  400598:	d65f03c0 	ret

000000000040059c <main>:
  40059c:	a9be7bfd 	stp	x29, x30, [sp, #-32]!
  4005a0:	910003fd 	mov	x29, sp
  4005a4:	528000a0 	mov	w0, #0x5                   	// #5
  4005a8:	b9001fa0 	str	w0, [x29, #28]		// [x29+28]=5
  4005ac:	528000c0 	mov	w0, #0x6                   	// #6
  4005b0:	b9001ba0 	str	w0, [x29, #24]		// [x29+24]=6
  4005b4:	910063a1 	add	x1, x29, #0x18		// x1=x29+0x18
  4005b8:	910073a0 	add	x0, x29, #0x1c		// x0=x29+0x1c
  4005bc:	97ffffe8 	bl	40055c <max>		// max(x0, x1)
  4005c0:	b9401fa1 	ldr	w1, [x29, #28]		// w1=[x29+28]
  4005c4:	90000000 	adrp	x0, 400000 <_init-0x3e8>
  4005c8:	911a4000 	add	x0, x0, #0x690
  4005cc:	97ffffa1 	bl	400450 <printf@plt>
  4005d0:	52800000 	mov	w0, #0x0                   	// #0
  4005d4:	a8c27bfd 	ldp	x29, x30, [sp], #32
  4005d8:	d65f03c0 	ret
  4005dc:	00000000 	.inst	0x00000000 ; undefined

#endif
